package com.xjtu.platform.user.admin.extramanage;

import com.xjtu.platform.common.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/admin/extraManage")
public class ExtraManageAPI {

    @Resource
    private GetAdditionalApplyService getAdditionalApplyService;


    @PostMapping("/getAdditionalApplyInfo")
    public Result getAdditionalApply(@RequestBody GetAdditionalApplyDto getAdditionalApplyDto){
        try {
            Map<String,Object> page = getAdditionalApplyService.getAdditionalApply(getAdditionalApplyDto);
            return Result.success(page);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.fail(Result.ERR_CODE_SYS,"系统错误......");
        }
    }

    @PostMapping("/permitExtra")
    public Result permitExtra(@RequestBody PermitExtraDto permitExtraDto){
        boolean ok = getAdditionalApplyService.permitExtra(permitExtraDto);
        if(ok){
            return Result.success("审核通过成功");
        }else {
            return Result.fail(Result.ERR_CODE_SYS,"系统错误.......");
        }
    }

    @PostMapping("/rejectExtra")
    public Result rejectExtra(@RequestBody RejectExtraDto rejectExtraDto ){
        boolean ok = getAdditionalApplyService.rejectExtra(rejectExtraDto);
        if(ok){
            return Result.success("审核已拒绝");
        }else {
            return Result.fail(Result.ERR_CODE_SYS,"系统错误.......");
        }
    }
}
